package com.itqf.controller;

import com.github.tobato.fastdfs.domain.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.itqf.entity.SysUser;
import com.itqf.service.SysUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/12/16
 * @Time: 下午2:28
 */
@RestController
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @Resource
    FastFileStorageClient fastFileStorageClient;//springboot 解析yml

    @RequestMapping("/find")
    public List<SysUser> find(){
        System.out.println(111);
        System.out.println(111);
        System.out.println(111);
        System.out.println(111);
        return sysUserService.findAll();
    }

    @RequestMapping("/upload")
    public Map upload(MultipartFile photo) {

        try {
            StorePath storePath = fastFileStorageClient.uploadFile(photo.getInputStream(),photo.getSize(),"gif",null);

            System.out.println(storePath.getFullPath());//ip group1/M00/00/00/Cgkwt1_Z2n-ABxl6AAA_0WgqiXw093.gif
            System.out.println(storePath.getGroup()+"---"+storePath.getPath());

            return  null;// {code:0,url:"http://10.9.48.183/group1/M00/00/00/Cgkwt1_Z2n-ABxl6AAA_0WgqiXw093.gif",msg:""}
        } catch (IOException e) {
            e.printStackTrace();
        }
        return  null;

    }
}
